#pragma once

#include "../SGD Wrappers/SGD_Handle.h"		//HTexture type
#include "..\SGD Wrappers\SGD_Geometry.h"	// geometry and math
#include "../SGD Wrappers/SGD_Listener.h"
#include "..\SGD Wrappers\SGD_Event.h"
#include <vector>

class ParticleSystem;



class BaseObject : public SGD::Listener
{
public:

	BaseObject();
	virtual ~BaseObject() = 0;

	//Interface
	virtual void Update(float dt);
	virtual void Render();


	virtual SGD::Rectangle	GetRect() const;
	virtual void HandleCollision( BaseObject* pOther);
	virtual void HandleEvent(const SGD::Event* pEvent){};



	/*************************************************************/
	//Accessors
	SGD::HTexture	 GetImage()		const		{ return m_hImage; }
	SGD::Point		 GetPosition()	const		{ return m_ptPosition; }
	SGD::Size		 GetSize()		const		{ return m_szSize; }
	SGD::HAudio		 GetAudio()		const		{ return m_aAudio; }
	std::vector<SGD::Point>*		 GetRectPoints()	const		{ return m_vtRectPoints; }
	ParticleSystem* GetParticle(int index)	const		{ return (m_vtParticle.size() == 0 ? nullptr : m_vtParticle[index]); }
	bool			 GetAlive()		const		{ return m_bAlive; }

	//Mutators
	void	SetImage(SGD::HTexture img)				{ m_hImage = img; }
	void	SetAudio(SGD::HAudio audio)				{ m_aAudio = audio; }
	void	SetPosition(SGD::Point pt)				{ m_ptPosition = pt; }
	void	SetSize(SGD::Size size)					{ m_szSize = size; }
	void	SetRotation(float angle)				{ m_fRotation = angle; }
	void	SetRectPoints(float angle);

	void	SetParticle(ParticleSystem particle);
	void	SetAlive(bool alive)					{ m_bAlive = alive; }


	virtual void	AddRef(void)				final;
	virtual void	Release(void)				final;


protected:
	//Members
	SGD::HTexture	m_hImage			= SGD::INVALID_HANDLE;		//image handle
	SGD::HAudio		m_aAudio			= SGD::INVALID_HANDLE;
	SGD::Point		m_ptPosition		= SGD::Point(0, 0);			//Position

	SGD::Size		m_szSize			= SGD::Size(0,0);			//Size

	std::vector<ParticleSystem*> m_vtParticle;
	float			m_fRotation			= 0.0f;						//Angle in radians
	SGD::Vector		m_vtRotationOffset	= SGD::Vector(0,0);
	bool			m_bAlive			= true;												// Is the player Alive?
	unsigned int	m_unRefCount		= 1;
	std::vector<SGD::Point>*	m_vtRectPoints;
};